home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 June: Reference Library / Dev.CD Jun 94.toast / Periodicals / develop / develop Issues 1-3 / develop Issue 2 code / Speed Development / UDemoDialogs.h < prev    next >
Encoding:
Text File  |  1990-02-26  |  8.7 KB  |  298 lines  |  [TEXT/MPS ]

  1. // UDemoDialogs.cp
  2. // Copyright © 1990 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UDEMODIALOGS__
  5. #define __UDEMODIALOGS__
  6. #include "Sane.h"
  7. #include "UMacApp.h"
  8. #include "UPrinting.h"
  9. #include "UGridView.h"
  10. #include "UTEView.h"
  11. #include "UDialog.h"
  12. #include "ToolUtils.h"
  13. #include "Fonts.h"
  14. #include "Resources.h"
  15. #include "Packages.h"
  16. #include "StdIO.h"
  17. #include "StdLib.h"
  18. #include "Strings.h"
  19.  
  20. #include "UGraph.h"
  21.  
  22. // Command numbers
  23. const short cMakePicture        = 1000;
  24.  
  25. // Miscellaneous constants
  26. const unsigned long kSignature    = 'SS01';         // Application signature
  27. const unsigned long kFileType    = 'SF01';        // File-type code used for document files
  28.                                                 // created by this application
  29. const short kTestWindowID        = 1001;            /* This is passed to NewSimpleWindow as the
  30.                                                  resource ID of the the WIND Resource which
  31.                                                  defines the window for this application's
  32.                                                  documents */
  33.  
  34. const short kMaxFonds            = 100;            // Max number of FONDs the FontList holds
  35.  
  36. // typdefs
  37. typedef short FontList[kMaxFonds];
  38.  
  39. typedef FontList *FontListPtr;
  40.  
  41. // class declarations
  42. class TTestApplication : public TApplication {
  43.   public:
  44.  
  45.     virtual pascal void ITestApplication(OSType itsMainFileType);
  46.         /* Initializes the application and globals. */
  47.  
  48.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  49.  
  50.     virtual pascal void DoSetupMenus(void);
  51.  
  52.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  53.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  54.  
  55. };
  56.  
  57. class TNumbersView : public TView {
  58.   public:
  59.  
  60.     virtual pascal void Draw(Rect *area);
  61.  
  62.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  63.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  64.  
  65. };
  66.  
  67. class TMonthlyDialog : public TDialogView {
  68.   public:
  69.  
  70.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  71.  
  72.     virtual pascal Boolean DeselectCurrentEditText(void);
  73.  
  74.     virtual pascal void DismissDialog(ResType dismisser);
  75.     
  76.     virtual pascal void StuffValues(void);
  77.  
  78.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  79.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  80.  
  81. };
  82.  
  83. class TModelessMarkDialog : public TDialogView {
  84.   public:
  85.  
  86.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  87.  
  88.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  89.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  90.  
  91. };
  92.  
  93. class TFontListView : public TTextListView {
  94.  
  95.   public:
  96.  
  97.     virtual pascal void InitFontList();
  98.     // Build an array of ids of font resources whose names are in alphabetical order
  99.     
  100.     virtual pascal void Free();
  101.     // Make sure the font list gets freed
  102.     
  103.     virtual pascal void GetItemText(short anItem, StringPtr aString);
  104.  
  105.     virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
  106.  
  107.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  108.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  109.  
  110.   private:
  111.             
  112.     FontListPtr    fFontList;
  113.  
  114. };
  115.  
  116. class TSizeListView : public TTextListView {
  117.  
  118.   public:
  119.  
  120.     virtual pascal void InitSizeList();
  121.     
  122.     virtual pascal void GetItemText(short anItem, StringPtr aString);
  123.  
  124.     virtual pascal void InstallFontFamily(short theFondIndex);
  125.  
  126.     virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
  127.  
  128.     virtual pascal void SetNumberOfItems(short aNumber);
  129.  
  130.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  131.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  132.  
  133.   private:
  134.             
  135.     short fSelection;
  136.     short fSelectedSize;
  137.     short fFondIndex;
  138.  
  139. };
  140.  
  141. class TPageSetupDialog : public TDialogView {
  142.  
  143.   public:
  144.   
  145.       TPageSetupDialog();                                    // constructor to initialize fOrientation
  146.  
  147.     virtual pascal void TPageSetupDialog::GetOrientation(VHSelect *theOrientation);
  148.  
  149.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  150.  
  151.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  152.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  153.  
  154.   private:
  155.   
  156.     VHSelect fOrientation;
  157.  
  158. };
  159.  
  160. class TRadioIcon :public  TIcon {
  161.   public:
  162.  
  163.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  164.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  165.  
  166.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  167.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  168. };
  169.  
  170. class THomeBrewDialog : public TDialogView {
  171.   public:
  172.  
  173.     virtual pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
  174.  
  175.     virtual pascal TView *HandleCursor(VPoint *theMouse, RgnHandle cursorRgn);
  176.  
  177.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  178.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  179. };
  180.  
  181. class TArrowsControl : public TPicture {
  182.  
  183.   public:
  184.  
  185.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  186.  
  187.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  188.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  189.  
  190.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  191.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  192.  
  193.   private:
  194.  
  195.     long fLastChange;                            /* tick count of last call to DoChoice */
  196.  
  197. };
  198.  
  199. class TTemperatureCluster : public TCluster {
  200.   public:
  201.  
  202.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  203.  
  204.     virtual pascal long GetValue();
  205.     
  206.     virtual pascal void SetValue(long newValue, Boolean redraw);
  207.  
  208.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  209.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  210. };
  211.  
  212. class TTemperatureConversionCluster : public TCluster {
  213.   public:
  214.  
  215.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  216.  
  217.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  218.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  219. };
  220.  
  221. class TSlider : public TPicture {
  222.  
  223.   public:
  224.  
  225.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  226.  
  227.     virtual pascal Boolean ContainsMouse(VPoint *theMouse);
  228.  
  229.     virtual pascal void Draw(Rect *area);
  230.  
  231.     virtual pascal void DrawKnob(void);
  232.  
  233.     virtual pascal void GetKnobRect(Rect *knobRect);
  234.  
  235.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  236.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  237.  
  238.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  239.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  240.  
  241.   private:
  242.  
  243.       short fValue;                                // current value of slider
  244.     PicHandle fKnobPicture;                        // handle to the PICT rsrc
  245.     Rect fKnobRect;                                // rect within which we draw the knob
  246.     short fMinTop;
  247.     short fMaxTop;
  248.  
  249. };
  250.  
  251. class TSumStaticText : public TStaticText {
  252.   public:
  253.  
  254.     virtual pascal void Draw(Rect *area);
  255.  
  256.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  257.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  258. };
  259.  
  260. class TCalcDialog : public TPicture {
  261.  
  262.   private: // since C++ allows enumerations with class scope, we'll take advantage of this:
  263.  
  264.     typedef enum {noOperator, divOperator, mulOperator, subOperator, addOperator} CalcOperator;
  265.  
  266.   public:
  267.  
  268.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  269.  
  270.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  271.  
  272.     virtual pascal void ClearSum(void);
  273.  
  274.     virtual pascal void FetchValue(long double *aValue);
  275.  
  276.     virtual pascal void SetValue(void);
  277.  
  278.     virtual pascal void TotalSum(CalcOperator newOperator);
  279.  
  280.     virtual pascal void NewDigit(short theNumber);
  281.  
  282.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  283.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  284.  
  285.   private:
  286.  
  287.     long double fSum;                            // note: the ANSI C standard "long double" is preferred 
  288.                                                 // over the IEEE standard "extended"
  289.     long double fArgument;                        // current argument to the calculator
  290.     CalcOperator fOperator;                        // operator for the equation
  291.     Boolean fDecimalPoint;                        // whether or not a decimal point is in the number
  292.     Boolean fRestart;                            // whether to restart entry of data (next number entered
  293.                                                 // corresponds to a new argument)
  294.  
  295. };
  296.  
  297. #endif
  298.